local function main (userOb, msgData)
    if msgData.key == "nickName" then
        local nick_name = msgData.context
        if not nick_name or nick_name == "" then
            ---! 昵称为空
            local result = {}
            result.error = 1
            result.key = msgData.key
            result.context = nick_name
            userOb:send_packet("MSGS2CSetPlayerInfo", result)
            return
        end

        if string.len(nick_name) > 50 then
            ---! 昵称过长
            local result = {}
            result.error = 2
            result.key = msgData.key
            result.context = nick_name
            userOb:send_packet("MSGS2CSetPlayerInfo", result)
            return
        end

        ---! 修改玩家昵称
        nick_name = userOb:set_nick_name(msgData.context)

        ---! 同步排行榜
        RANK_D:sync_rank_data(userOb)

        local result = {}
        result.error = 0
        result.key = msgData.key
        result.context = nick_name
        userOb:send_packet("MSGS2CSetPlayerInfo", result)
        return
    end
end

COMMAND_D:register_command("MSGC2SSetPlayerInfo",GameCmdType.NONE, main)
